
import java.util.Date;
import java.util.UUID;

// 影片类
class Movie {
    private String name;
    private String director;
    private String actors;
    private String introduction;
    private int duration;
    private double rating;

    public Movie(String name, String director, String actors, String introduction, int duration, double rating) {
        this.name = name;
        this.director = director;
        this.actors = actors;
        this.introduction = introduction;
        this.duration = duration;
        this.rating = rating;
    }

    // Getter和Setter
    public String getName() { return name; }
    public String getDirector() { return director; }
    public String getActors() { return actors; }
    public String getIntroduction() { return introduction; }
    public int getDuration() { return duration; }
    public double getRating() { return rating; }
    public void setRating(double rating) { this.rating = rating; }

    // 显示影片信息
    public void displayInfo() {
        System.out.println("影片名称: " + name);
        System.out.println("导演: " + director);
        System.out.println("主演: " + actors);
        System.out.println("简介: " + introduction);
        System.out.println("时长: " + duration + "分钟");
        System.out.println("评分: " + rating);
    }
}

// 场次类
class Show {
    private String showId;
    private Movie movie;
    private CinemaHall hall;
    private Date showTime;
    private double price;
    private Seat[][] seats;

    public Show(Movie movie, CinemaHall hall, Date showTime, double price) {
        this.showId = UUID.randomUUID().toString();
        this.movie = movie;
        this.hall = hall;
        this.showTime = showTime;
        this.price = price;
        this.seats = hall.initSeats();
    }

    // 获取座位
    public Seat getSeat(int row, int col) {
        if (row >= 1 && row <= seats.length && col >= 1 && col <= seats[0].length) {
            return seats[row-1][col-1];
        }
        return null;
    }

    // 显示座位状态
    public void displaySeatStatus() {
        System.out.println("  " + getColumnLabels());
        for (int i = 0; i < seats.length; i++) {
            System.out.print((i+1) + " ");
            for (int j = 0; j < seats[i].length; j++) {
                System.out.print(seats[i][j].isSold() ? "X " : "O ");
            }
            System.out.println();
        }
    }

    private String getColumnLabels() {
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= seats[0].length; i++) {
            sb.append(i).append(" ");
        }
        return sb.toString();
    }

    // Getter和Setter
    public String getShowId() { return showId; }
    public Movie getMovie() { return movie; }
    public CinemaHall getHall() { return hall; }
    public Date getShowTime() { return showTime; }
    public double getPrice() { return price; }
    public Seat[][] getSeats() { return seats; }
}